home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d909.lha / GoldED2 / Tools / HiSpeed / arexx / AjustBook.rexx < prev    next >
OS/2 REXX Batch file  |  1993-08-28  |  2KB  |  103 lines

  1. /*
  2.     This script is used to adjust layout (borders) of a document
  3.     to book mode. The goal is adjust the block with to the line
  4.     width of your text (in other words: make border/dx as big as
  5.     posssible).
  6. */
  7.  
  8. options results
  9.  
  10. address HISPEED.1
  11.  
  12. SET REQUESTER ON
  13.  
  14. QUERY BOOK
  15.  
  16. if RESULT ~= ON then
  17.   do
  18.  
  19.     SET ASK "This script has been developed for BOOK mode|Switch to BOOK mode ?"
  20.  
  21.     if RESULT = 1 then
  22.         SET BOOK ON
  23.     else
  24.         exit
  25.   end
  26.  
  27. SET ASK "This script will adjust block width to maximum|column width of your document(s). The goal is to|center columns on page. Proceed ?"
  28.  
  29. if RESULT = 1 then
  30.  
  31.   do
  32.     QUERY JOBS
  33.  
  34.     if RESULT = 0 then
  35.       REQUESTFILE
  36.  
  37.     QUERY JOBS
  38.  
  39.     if RESULT ~= 0 then
  40.  
  41.       do
  42.  
  43.         SET REQUESTER OFF        /* we don't want any scan info window */
  44.  
  45.         SET LEFT 15              /* implies right = 15, too */
  46.         SET DX   0
  47.         SCAN
  48.  
  49.         QUERY MAXLINE
  50.         maxline = RESULT
  51.  
  52.         QUERY BLOCKX
  53.         width = RESULT
  54.  
  55.         done = 0
  56.  
  57.         do UNTIL (done ~= 0)
  58.  
  59.           QUERY LEFT
  60.           border = RESULT
  61.  
  62.           QUERY DX
  63.           distance = RESULT
  64.  
  65.           if width = maxline then
  66.  
  67.             done = 1
  68.  
  69.           else do
  70.  
  71.             if width < maxline then
  72.               done = 1
  73.  
  74.             else do
  75.  
  76.               if (border * 2) < distance then
  77.                 do
  78.                   border = border + 1
  79.                   SET LEFT border
  80.                 end
  81.  
  82.               else do
  83.                 distance = distance + 1
  84.                 SET DX distance
  85.               end
  86.  
  87.               QUERY BLOCKX
  88.               width = RESULT
  89.             end
  90.           end
  91.         end
  92.  
  93.         SET REQUESTER
  94.  
  95.         if (width < maxline) then
  96.           SET WARN "Couldn't adjust: lines too long"
  97.         else
  98.           SET WARN "Ok, we got it right."
  99.  
  100.       end
  101.  
  102.   end
  103.